package com.sky.youxue.service;

import com.sky.youxue.mapper.UserSizeMapper;
import com.sky.youxue.user.pojo.UserSize;
import com.sun.org.apache.xpath.internal.operations.Bool;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class UserSizeService {

    @Autowired
    private UserSizeMapper userSizeMapper;


    public Boolean insertUserSize(UserSize userSize){
        String rolename = userSize.getRolename();
        Long user_id = userSize.getUser_id();
        if(rolename == null || user_id == null){
            return false;
        }
        Boolean result = this.userSizeMapper.insertSelective(userSize)==1;
        return result;
    }

    public Boolean updateUserSize(UserSize userSize){
        int count = userSizeMapper.updateByPrimaryKeySelective(userSize);
        return count==1;
    }

    public UserSize queryUserSizeById(Long roleid){
        UserSize recode = new UserSize();
        recode.setRoleid(roleid);
        UserSize userSize = userSizeMapper.selectOne(recode);
        if(userSize == null){
            return null;
        }
        return userSize;
    }

    public Boolean deleteUserSize(UserSize userSize){
        int count = this.userSizeMapper.deleteByPrimaryKey(userSize);
        return count==1;
    }
}
